<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>添加餐桌-订餐管理系统</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../static/css/font.css">
		<link rel="stylesheet" href="../../static/css/weadmin.css">
		<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
		<!--[if lt IE 9]>
	      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
	      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
	    <![endif]-->
	</head>

	<body>
		<div class="weadmin-body">
			<form class="layui-form">
				<div class="layui-form-item">
					<label class="layui-form-label">
		                <span class="we-red">*</span>新桌名
		            </label>
					<div class="layui-input-inline">
						<input type="text" id="boardName" name="boardName" lay-verify="required|nikename" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">
              </label>
					<button id="add" class="layui-btn" lay-filter="add" lay-submit="">确定</button>
				</div>
			</form>
		</div>
		<script src="../../lib/layui/layui.js" charset="utf-8"></script>
		<script src="../../static/js/jquery.js"></script>
		<script src="../../static/js/setAjax.js"></script>
		<script>
			layui.use(['form', 'layer'], function() {
				var form = layui.form,
						layer = layui.layer;
				//监听提交
				form.on('submit(add)', function(data) {
					$.ajax({
						url:'/board',
						type:'post',
						data:data.field,
						success:function (data) {
							data = JSON.parse(data);
							if (data.state=="success"){
								layer.msg(data.message,{icon:1,time:2000},function () {
									parent.location.reload();
									var index = parent.layer.getFrameIndex(window.name);
									//关闭当前iframe
									parent.layer.close(index);
								});
							} else {
								layer.msg(data.message,{icon:2,time:2000})
							}
						},
						error:function () {
							console.log("出错了");
						}
					});
					return false;
				});

			});
		</script>
	</body>

</html>